<template>
  <div class="contentItem" v-for="(item,index) in tableData" :key="index">
    <div class="zz" @click="goDetail(item.id,item.rec_id)"></div>
    <div class="icon" :style="{'background':item.recStatus===0?'#597EF7':'#36CFC9'}">Task</div>
    <div class="text">
      <div class="textTitle">{{item.title}}</div>
      <div class="desc">{{item.synopsis}}</div>
      <div class="d-fix">
        <div v-if="item.pushName">
          <span class="name">发布人：{{item.pushName}} </span>
        </div>
        <div v-if="item.meetName">
          <span class="name">接单：{{item.meetName}} </span>
        </div>

        <div v-if="item.reason">
          <span class="name color-red">驳回理由：{{item.reason}} </span>
        </div>
      </div>
    </div>
    <div class="integralIcon">
      <img src="@/assets/img/jifen.png" v-if="item.type == 2">
      <img src="@/assets/img/yue.png" v-if="item.type == 1">
      <span v-if="item.type == 2">{{item.integral}}积分</span>
      <span v-if="item.type == 1">{{item.money}}余额</span>
    </div>
    <div class="btn">
      <span v-if="types == 1">
        <span v-if=" item.is_del == 3">
            <span class="taskingBtn red" >已结束</span>
        </span>

        <span v-else>
          <span v-if="
          item.recStatus=== 0
          && item.task_type!=4    //不是知识库
          && (item.ad_id !== admin_id)
          && (admin_id!==1)
"
                class="taskBtn" @click="goSeekHelpDetail(index)">领取任务</span>
          <span v-if="item.recStatus=== 1" class="taskingBtn" >进行中</span>
          <span v-if="item.recStatus=== 2" class="taskingBtn" >审核中</span>
          <span v-if="item.recStatus=== 3" class="taskingBtn" >已通过</span>
       </span>
      </span>

      <div class="dfix" v-if="types == 1 && item.is_del == 0">
        <span v-if="item.task_type!=4">
          <span class="taskBtn mar mat10" v-if="authRole('Learn.Task.DelTask') && (item.ad_id === admin_id || admin_id === 1)" @click="deletes(index)">删除</span>
          <span class="taskBtn mar mat10" v-if="authRole('Learn.Task.endTask') && (item.ad_id === admin_id || admin_id === 1)" @click="deletesEnd(index)">结束</span>
        </span>
          <span class="taskBtn mar" v-if="authRole('Learn.Task.editTask') && (item.ad_id === admin_id || admin_id === 1)" @click="edit(index)">编辑</span>
      </div>
      <div class="dfix" v-if="types == 2 && searchObj">
        <span v-if="searchObj.status=== 2" class="taskBtn mar" @click="hadleTask(3,item.rec_id)">审核</span>
        <span v-if="searchObj.status=== 2" class="taskBtn mar bg" @click="hadleTask(1,item.rec_id)" >驳回</span>
      </div>
    </div>
  </div>
</template>

<script>
  import { isAuth } from '../../utils'

  export default {
    name: 'TaskContent',
    props: {
      tableData: {
        type: Object
      },
      types: {
        type: String,
        default: '1'
      },
      searchObj: {
        type: Object
      }
    },
    emits: ['godetail','goseekhelpdetail','deletes','edit','hadleTask','deletesend'],
    setup(props,context){
      const goDetail = (id,rec_id) => {
        context.emit("godetail",id,rec_id)
      }
      let user = window.localStorage.getItem('user');
      let userInfo = eval('(' + user + ')');
      const admin_id = userInfo.id
      const goSeekHelpDetail = (index) => {
        context.emit("goseekhelpdetail",index)
      }
      const deletes = (index) => {
        context.emit("deletes",index)
      }
      const edit = (index) => {
        context.emit("edit",index)
      }
      const hadleTask = (type,index) => {
        context.emit("hadletask",type,index)
      }
      const authRole = (url)=>{
          return isAuth(url)
      }
      //结束
      const deletesEnd = (index) => {
        context.emit("deletesend",index)
      }
      return {
        goSeekHelpDetail,
        goDetail,
        authRole,
        deletes,
        edit,
        hadleTask,
        deletesEnd,
        admin_id
      }
    }
  }
</script>

<style lang="scss" scoped>
  .color-red {
    color: red !important;
  }
  .mat10 {
    margin-bottom: 5px;
  }
  .contentItem {
    position: relative;
    height: 100%;
    border-top: 1px solid #E9E9E9;
    display: flex;
    font-size: 14px;
    padding: 10px;
  .icon {
    width: 68px;
    height: 68px;
    color: #fff;
    border-radius: 2px;
    background-color: #36CFC9FF;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 16px;
  }
    .red {
      color: red!important;
      border: 1px solid red!important;
    }
    .d-fix {
      display: flex;
      justify-content: space-between;
      width: 60%;
      font-size: 12px;
      .name {
        color: #3a8ee6;
        font-width: 600;
      }
      .date {
        font-size: 11px;
        color: #a99999;
      }
    }
    .bg {
      color: #dc1c1c !important;
      border: 1px solid #dc1c1c !important;
    }
    .zz {
      position: absolute;
      top: 0;
      height: 100%;
      width: 80%;
      cursor:pointer
    }
    .zz:hover {
      background: #f9f9f9;
      opacity: 0.5;
    }
  .text {
    cursor: pointer;
    margin-left: 24px;
    flex: 3;
    margin-right: 20px;
    padding-top: 3px;
  .textTitle {
    color: #000000A6;
    font-weight: 600;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .desc {
    padding-top: 6px;
    color: #00000073;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
  }

  p {
    color: #00000073;
  }
  }

  .integralIcon{
    flex: 1;
    display: flex;
    align-items: center;
    padding-top: 18px;
  img{
    width: 22px;
    height: 22px;
  }
  span {
    color: #00000073;
    font-size: 14px;
    margin-left:2px;
  }
  }
  .btn {
    margin-right: 58px;

  .taskBtn{
    width: 74px;
    height: 32px;
    display: grid;
    place-items: center;
    color:#1890FFFF;
    border: 1px solid #1890FFFF;
    cursor: pointer;
    z-index: 2;
  }
  .taskingBtn{
    width: 74px;
    height: 32px;
    display: grid;
    place-items: center;
    color:#1890FFFF;
    border: 1px solid #1890FFFF;
    cursor: pointer;
    opacity: 0.5;
  }
  }
  }
  .dfix {
    display: flex;
    margin-top: 5px;
  }
  .mar {
    margin-right: 5px;
  }
  .taskBtn:active {
    background: #f1f1f1;
  }
</style>
